package com.adaxi.adc.business.manager.controller;

import com.adaxi.adc.business.manager.pojo.PassengerTrip;
import com.adaxi.adc.business.manager.pojo.Vehicle;
import com.adaxi.adc.business.manager.service.VehicleTripService;
import com.adaxi.adc.business.manager.service.impl.*;
import com.adaxi.adc.business.manager.vo.WeekCarVo;
import com.adaxi.adc.business.manager.vo.WeekPassengerVo;
import com.adaxi.adc.common.common.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "[后台管理系统]首页接口", value = "SHomeController")
public class SHomeController {
    @Autowired
    PassengerTripLocationServiceImpl passengerTripLocationService;
    @Autowired
    VehicleServiceImpl vehicleService;
    @Autowired
    VehicleTripServiceImpl vehicleTripService;
    @Autowired
    PassengerServiceImpl passengerService;
    @Autowired
    PassengerTripServiceImpl passengerTripService;


//查询乘客人数
/*@GetMapping("/count-people")
@ApiOperation(value = "查询乘客人数", notes = "查询乘客人数")
    public CommonResult  query(){

    return CommonResult.SUCCESS("Hello World  success i  am  manager");
    }
    */
// 查询乘客人数
@GetMapping("/count-people")
@ApiOperation(value = "查询注册人数", notes = "查询注册人数")
public CommonResult<Integer> query() {
    // 统计查询乘客人数
    long count = passengerService.count(null);
    return CommonResult.SUCCESS("查询注册人数成功",(int) count);
}
    //查询行程数量统计
    @GetMapping("/count-trip")
    @ApiOperation(value = "查询行程数量", notes = "查询行程数量")
    public CommonResult  query2(){
            //统计查询行程数量
        long count=vehicleTripService.count(null);
        return CommonResult.SUCCESS("查询行程成功",(int) count);
    }
    @GetMapping("/count-car")
    @ApiOperation(value = "查询车辆数量", notes = "查询车辆数量")
    public CommonResult  query3(){
            //统计车辆数量
        long count=vehicleService.count(null);
        return CommonResult.SUCCESS("查询行程成功",(int) count);
    }

    @GetMapping("/week-passenger")
    @ApiOperation(value = "查询近七天每天的人数", notes = "查询近七天每天的人数")
    public CommonResult  weekPassenger(){
        List<WeekPassengerVo> passengerCount = passengerTripService.weekPassenger();
        return CommonResult.SUCCESS("查询成功",passengerCount);
    }
    @GetMapping("/week-car")
    @ApiOperation(value = "查询近七天每天的拼单量", notes = "查询近七天每天的拼单量")
    public CommonResult  weekCar(){
        List<WeekCarVo> carCount = vehicleTripService.weekCar();
        return CommonResult.SUCCESS("查询成功",carCount);
    }

    @GetMapping("/crate-passenger")
    @ApiOperation(value = "查询近七天活跃用户", notes = "查询近七天活跃用户")
    public CommonResult  cratePassenger(){
        int passenger = passengerTripService.createPassenger();
        return CommonResult.SUCCESS("查询成功",passenger);
    }

}
